//
//  CommentProgressCell.m
//  ForestPack
//
//  Created by jimmy on 2018/8/6.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "CommentProgressCell.h"
#import "EmployerCommentTool.h"
#import "UIView+Utils.h"

@interface CommentProgressCell()

@property (nonatomic,strong)  ZZGradientProgress  * circle1;
@property (nonatomic,strong)  ZZGradientProgress  * circle2;
@property (nonatomic,strong)  ZZGradientProgress  * circle3;
@property (nonatomic,strong)  ZZGradientProgress  * circle4;
@property (nonatomic,strong)  UILabel  * scoreLabel1;
@property (nonatomic,strong)  UILabel  * scoreLabel2;
@property (nonatomic,strong)  UILabel  * scoreLabel3;
@property (nonatomic,strong)  UILabel  * scoreLabel4;


@end

@implementation CommentProgressCell
//cell height:90
+(CommentProgressCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"CommentProgressCell";
    CommentProgressCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[CommentProgressCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    return cell;
    
}

- (void)setEmployerCommentModel:(EmployerCommentModel *)employerCommentModel
{
    _employerCommentModel = employerCommentModel;
    
    self.scoreLabel1.text = [NSString stringWithFormat:@"%@",employerCommentModel.total_star];
    self.scoreLabel2.text = [NSString stringWithFormat:@"%@",employerCommentModel.quality_star];
    self.scoreLabel3.text = [NSString stringWithFormat:@"%@",employerCommentModel.speed_star];
    self.scoreLabel4.text = [NSString stringWithFormat:@"%@",employerCommentModel.server_star];
    
    self.circle2.progress = [employerCommentModel.quality_star doubleValue]/5.0;
    self.circle3.progress = [employerCommentModel.speed_star doubleValue]/5.0;
    self.circle4.progress = [employerCommentModel.server_star doubleValue]/5.0;
}

-(void)createSubView
{
    //1.半圆弧形  综合得分
    self.circle1 = [[ZZGradientProgress alloc] initWithFrame:CGRectMake(ScreenX375(30), ScreenX375(18), ScreenX375(92), ScreenX375(92)) startColor:[UIColor yellowColor] endColor:[UIColor redColor] startAngle:175 reduceAngle:140 strokeWidth:5];
    self.circle1.progress = 0.85;
    self.circle1.showProgressText = NO;
    [self addSubview:self.circle1];
    
    self.scoreLabel1 = [[UILabel alloc] init];
    self.scoreLabel1.text = @"5.0";
    [self.scoreLabel1 sizeToFit];
    [self.scoreLabel1 setCenter:CGPointMake(CGRectGetMidX(self.circle1.frame), CGRectGetMidY(self.circle1.frame)-20)];
    [self addSubview:self.scoreLabel1];
    
    UILabel *label1 = [[UILabel alloc] init];
    label1.text = @"综合得分";
    label1.font = Kfont(13);
    [label1 sizeToFit];
    [label1 setCenter:CGPointMake(CGRectGetMidX(self.circle1.frame), CGRectGetMidY(self.circle1.frame))];
    [self addSubview:label1];
    
    UILabel *lineLabel = [[UILabel alloc] init];
    lineLabel.frame = CGRectMake(self.circle1.right + ScreenX375(30), ScreenX375(12), 1, ScreenX375(66));
    lineLabel.backgroundColor = FONTCOLOR_LIGHTGRAY;
    [self addSubview:lineLabel];
    
    //2. 完成质量
    self.circle2 = [[ZZGradientProgress alloc] initWithFrame:CGRectMake(self.circle1.right + 59, ScreenX375(8), ScreenX375(66), ScreenX375(66)) startColor:[UIColor yellowColor] endColor:[UIColor redColor] startAngle:0 reduceAngle:0 strokeWidth:5];
    self.circle2.backgroundColor = [UIColor whiteColor];
    self.circle2.radius = 25;
    self.circle2.roundStyle = YES;
    self.circle2.showProgressText = NO;
    self.circle2.showPathBack = YES;
    self.circle2.pathBackColor = [UIColor lightGrayColor];
    self.circle2.colorGradient = NO;
    self.circle2.progress = 3.2/5.0;
    [self addSubview:self.circle2];
    
    self.scoreLabel2 = [[UILabel alloc] init];
    self.scoreLabel2.text = @"5.0";
    [self.scoreLabel2 sizeToFit];
    [self.scoreLabel2 setCenter:CGPointMake(CGRectGetMidX(self.circle2.frame), CGRectGetMidY(self.circle2.frame))];
    [self addSubview:self.scoreLabel2];
    
    UILabel *label2 = [[UILabel alloc] init];
    label2.text = @"完成质量";
    label2.font = Kfont(12);
    [label2 sizeToFit];
    [label2 setCenter:CGPointMake(CGRectGetMidX(self.circle2.frame), CGRectGetMaxY(self.circle2.frame))];
    [self addSubview:label2];
    
    //3. 工作速度
    self.circle3 = [[ZZGradientProgress alloc] initWithFrame:CGRectMake(self.circle2.right, ScreenX375(8), ScreenX375(66), ScreenX375(66)) startColor:[UIColor yellowColor] endColor:[UIColor redColor] startAngle:0 reduceAngle:0 strokeWidth:5];
    self.circle3.backgroundColor = [UIColor whiteColor];
    self.circle3.radius = 25;
    self.circle3.roundStyle = YES;
    self.circle3.showProgressText = NO;
    self.circle3.showPathBack = YES;
    self.circle3.pathBackColor = [UIColor lightGrayColor];
    self.circle3.colorGradient = NO;
    self.circle3.progress = 5.0/5.0;
    [self addSubview:self.circle3];
    
    self.scoreLabel3 = [[UILabel alloc] init];
    self.scoreLabel3.text = @"5.0";
    [self.scoreLabel3 sizeToFit];
    [self.scoreLabel3 setCenter:CGPointMake(CGRectGetMidX(self.circle3.frame), CGRectGetMidY(self.circle3.frame))];
    [self addSubview:self.scoreLabel3];
    
    UILabel *label3 = [[UILabel alloc] init];
    label3.text = @"工作速度";
    label3.font = Kfont(12);
    [label3 sizeToFit];
    [label3 setCenter:CGPointMake(CGRectGetMidX(self.circle3.frame), CGRectGetMaxY(self.circle2.frame))];
    [self addSubview:label3];
    
    //4. 服务态度
    self.circle4 = [[ZZGradientProgress alloc] initWithFrame:CGRectMake(self.circle3.right, ScreenX375(8), ScreenX375(66), ScreenX375(66)) startColor:[UIColor yellowColor] endColor:[UIColor redColor] startAngle:0 reduceAngle:0 strokeWidth:5];
    self.circle4.backgroundColor = [UIColor whiteColor];
    self.circle4.radius = 25;
    self.circle4.roundStyle = YES;
    self.circle4.showProgressText = NO;
    self.circle4.showPathBack = YES;
    self.circle4.pathBackColor = [UIColor lightGrayColor];
    self.circle4.colorGradient = NO;
    self.circle4.progress = 4.8/5.0;
    [self addSubview:self.circle4];
    
    self.scoreLabel4 = [[UILabel alloc] init];
    self.scoreLabel4.text = @"5.0";
    [self.scoreLabel4 sizeToFit];
    [self.scoreLabel4 setCenter:CGPointMake(CGRectGetMidX(self.circle4.frame), CGRectGetMidY(self.circle4.frame))];
    [self addSubview:self.scoreLabel4];
    
    UILabel *label4 = [[UILabel alloc] init];
    label4.text = @"服务态度";
    label4.font = Kfont(12);
    [label4 sizeToFit];
    [label4 setCenter:CGPointMake(CGRectGetMidX(self.circle4.frame), CGRectGetMaxY(self.circle4.frame))];
    [self addSubview:label4];
    
}


@end
